
//查询黑名单
import Vue from "vue";

//中国标准时间转字符串YY:MM:DD HH:mm:ss
export const msToDate=(msec)=>{
  let datetime = new Date(msec);
  let year = datetime.getFullYear();
  let month = datetime.getMonth() + 1;
  let date = datetime.getDate();
  let result = year +
    '-' +
    ((month) < 10 ? '0' + month : month ) +
    '-' +
    ((date) < 10 ? '0' + date : date) ;
  return result;
}


export const webList = (self, tiyData) => {
  self.$Spin.show();
  self.$ySpliceAll(tiyData.tData.list);
  let param = {
    "pageSize": tiyData.tPage.stepNumber,
    "pageNum": tiyData.tPage.currentPage,
  };
  //iview时间控件显示为utc时间，会转成本地时间，这里再转回来
  if(tiyData.tParam.startTime){
    param.startTime = self.$tiyQueryTime(new Date(Date.parse(tiyData.tParam.startTime)).getTime(), 'yyyy-MM-dd');
  }
  if(tiyData.tParam.endTime){
    param.endTime =  self.$tiyQueryTime(new Date(Date.parse(tiyData.tParam.endTime)).getTime(), 'yyyy-MM-dd');
  }

  self.$ApiProductSource.queryStatistics(param).then(function (response) {
    if(response.success){
      let data = response.result;
      tiyData.tPage.total = data.total;
      tiyData.tPage.stepNumber = data.pageSize;
      data.list.forEach(
        function (item) {
          tiyData.tData.list.push(item);
        }
      );
    }else{
      self.$Message.error(response.errorMessage);
    }
    self.$Spin.hide();
  });
};


function changeModelLoading(self, tiyData) {
  tiyData.tStatus.modalDelete.isLoading = false;
  self.$nextTick(function () {
    tiyData.tStatus.modalDelete.isLoading = true;
  });

  tiyData.tStatus.modalAdd.isLoading = false;
  self.$nextTick(function () {
    tiyData.tStatus.modalAdd.isLoading = true;
  });
}
